<template>
  <div>
    <div class="container">
      <i-input v-model="sreachData" size="large" class="sreach" >
        <Button slot="append"  @click="sreach()">搜索</Button>
<!--        -->
      </i-input>
      <Tag v-for="(item, index) in promotionTags" :key="index" closable  @on-close="closeTags(index)"><span @click="selectTags(index)">{{item}}</span></Tag>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Search',
  data () {
    return {
      sreachData: '',
      promotionTags: ['买2免1', '领200神券', '199减100', '母婴5折抢', '充100送20']
    };
  },
  methods: {
    closeTags (index) {
      this.promotionTags.splice(index, 1);
    },
    selectTags (index) {
      this.sreachData = this.promotionTags[index];
    },
    sreach () {
      console.log("" +
        "！！！！！！！！！！！！！！！");
      if(this.sreachData == "")
      {
        this.$Message.error("搜索内容不能为空");
        return false;
      }
      else
      {
        this.$http.get("/product/keysearch/{keyword}?keyword="+this.sreachData).then(resp => {
          const res = resp.data.data;
          const obj={
            searchList:[],
            total: 0
          };
          if (resp.data.code === 200) {
            obj.searchList = res
            obj.total = res.length
            this.$emit('searchClick',obj);
            //this.getOrderList()
          } else {
            this.$Message.error('商品数据请求失败');
          }
          // _this.current = 1
        });
        // this.$router.push({path: '/goodList', query: { keyword: this.sreachData }});
      }

    }
  }
};
</script>

<style scoped>
.container {
  padding-top: 15px;
  margin: 0px auto;
  margin-bottom: 15px;
  width: 460px;
}
.sreach {
  margin: 5px 0px;
}
</style>
